package com.itheima.demo6collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionTraversalDemo3 {
    public static void main(String[] args) {
        Collection<String> c=new ArrayList<>();
        c.add("hello");
        c.add("world");
        c.add("java");
        System.out.println( c);
        //得到这个集合的迭代器对象
        Iterator<String> i1 = c.iterator();
        //通过循环来遍历
        while(i1.hasNext()){
            String s = i1.next();
            System.out.println(s);
        }
    }
}
